﻿using SAP.Middleware.Connector;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RPAAction.CSRFC
{
    class IRfcTableRPADataReaderWithTag : IRfcTableRPADataReader
    {
        /// <summary>
        /// tagTitle 和 tagValue 参数用来标记输出的SAP数据
        /// </summary>
        /// <param name="rfcTable"></param>
        /// <param name="tagTiele"></param>
        /// <param name="tagValue"></param>
        public IRfcTableRPADataReaderWithTag(IRfcTable rfcTable, string tagTitle, object tagValue)
            : base(rfcTable)
        {
            TagTitle = tagTitle;
            TagValue = tagValue;
        }

        public override int FieldCount => base.FieldCount + 1;

        public override string GetName(int ordinal)
        {
            return ordinal == 0 ? TagTitle : base.GetName(ordinal - 1);
        }

        public override object GetValue(int ordinal)
        {
            return ordinal == 0 ? TagValue : base.GetValue(ordinal - 1);
        }

        private readonly string TagTitle;
        private readonly object TagValue;
    }
}
